# Data analysis condensed script for 'Premature mortality and timing of your life: An exploratory correlational study'
# Mona Joly and colleagues
# 11/03/21

rm(list=ls())

### Loading required packages ####

if(!require(tidyverse)){
  install.packages("tidyverse")
  library(tidyverse)
}
## Loading required package: tidyverse
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2     ✓ purrr   0.3.4
## ✓ tibble  3.0.4     ✓ dplyr   1.0.2
## ✓ tidyr   1.1.2     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
if(!require(tidylog)){ 
  install.packages("tidylog")
  library(tidylog)
}
## Loading required package: tidylog
## 
## Attaching package: 'tidylog'
## The following objects are masked from 'package:dplyr':
## 
##     add_count, add_tally, anti_join, count, distinct, distinct_all,
##     distinct_at, distinct_if, filter, filter_all, filter_at, filter_if,
##     full_join, group_by, group_by_all, group_by_at, group_by_if,
##     inner_join, left_join, mutate, mutate_all, mutate_at, mutate_if,
##     relocate, rename, rename_all, rename_at, rename_if, rename_with,
##     right_join, sample_frac, sample_n, select, select_all, select_at,
##     select_if, semi_join, slice, slice_head, slice_max, slice_min,
##     slice_sample, slice_tail, summarise, summarise_all, summarise_at,
##     summarise_if, summarize, summarize_all, summarize_at, summarize_if,
##     tally, top_frac, top_n, transmute, transmute_all, transmute_at,
##     transmute_if, ungroup
## The following objects are masked from 'package:tidyr':
## 
##     drop_na, fill, gather, pivot_longer, pivot_wider, replace_na,
##     spread, uncount
## The following object is masked from 'package:stats':
## 
##     filter
if(!require(rmarkdown)){
  install.packages("rmarkdown")
  library(rmarkdown)
}
## Loading required package: rmarkdown
if(!require(multilevel)){
  install.packages("multilevel")
  library(multilevel)
}                           # for sobel test
## Loading required package: multilevel
## Loading required package: nlme
## 
## Attaching package: 'nlme'
## The following object is masked from 'package:dplyr':
## 
##     collapse
## Loading required package: MASS
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:tidylog':
## 
##     select
## The following object is masked from 'package:dplyr':
## 
##     select
if(!require(bda)){
  install.packages("bda")
  library(bda)
}                           # another way to calculate sobel test
## Loading required package: bda
## Loading required package: boot
## bda v15 (Bin Wang, 2020)
# if(!require(lme4)) install.packages("lme4") # for mixed-effects models
if(!require(sjlabelled)){
  install.packages("sjlabelled")
  library(sjlabelled)
}                           # all the sj**** : for graphical representation
## Loading required package: sjlabelled
## 
## Attaching package: 'sjlabelled'
## The following object is masked from 'package:forcats':
## 
##     as_factor
## The following object is masked from 'package:dplyr':
## 
##     as_label
if(!require(sjmisc)) {
  install.packages("sjmisc")
  library(sjmisc)
}
## Loading required package: sjmisc
## 
## Attaching package: 'sjmisc'
## The following object is masked from 'package:tidylog':
## 
##     replace_na
## The following object is masked from 'package:purrr':
## 
##     is_empty
## The following object is masked from 'package:tidyr':
## 
##     replace_na
## The following object is masked from 'package:tibble':
## 
##     add_case
if(!require(sjstats)){
  install.packages("sjstats")
  library(sjstats)
}
## Loading required package: sjstats
if(!require(ggeffects)){
  install.packages("ggeffects")
  library(ggeffects)
}
## Loading required package: ggeffects
if(!require(sjPlot)) {
  install.packages("sjPlot")
  library(sjPlot)
}
## Loading required package: sjPlot
if(!require(effects)){
  install.packages("effects")
  library(effects)
}
## Loading required package: effects
## Loading required package: carData
## lattice theme set by effectsTheme()
## See ?effectsTheme for details.
### Loading the data ####

# setwd("/Users/monou/Nextcloud/Family history questionnaire/Data analysis") # Mac France Mona
# setwd("/Users/Monouille/Nextcloud/Shared/HSI/Family history questionnaire/Data analysis/FamHist") # Macbook Mona

d <- read.table("data_famhist.txt",dec=",",sep="\t",header=TRUE)        # Read final data

lapply(d, class)
## $prolific_id
## [1] "character"
## 
## $Progress
## [1] "integer"
## 
## $Duration
## [1] "integer"
## 
## $Finished
## [1] "character"
## 
## $RecordedDate
## [1] "character"
## 
## $UserLanguage
## [1] "character"
## 
## $consent
## [1] "character"
## 
## $gender
## [1] "character"
## 
## $age
## [1] "integer"
## 
## $look_after_health
## [1] "integer"
## 
## $checkup
## [1] "character"
## 
## $smoker
## [1] "integer"
## 
## $environment_1
## [1] "integer"
## 
## $env_transport
## [1] "integer"
## 
## $extrinsic_risk
## [1] "integer"
## 
## $children
## [1] "integer"
## 
## $age_first_child
## [1] "integer"
## 
## $breastfeed_yesno
## [1] "integer"
## 
## $breastfeed_length
## [1] "character"
## 
## $ideal_age
## [1] "integer"
## 
## $parents_dead
## [1] "integer"
## 
## $parent1_age_1
## [1] "character"
## 
## $parent1_age_2
## [1] "integer"
## 
## $parent1_control_1
## [1] "integer"
## 
## $parent1_close_1
## [1] "integer"
## 
## $parent2_age_1
## [1] "character"
## 
## $parent2_age_2
## [1] "integer"
## 
## $parent2_control_1
## [1] "integer"
## 
## $parent2_close_1
## [1] "integer"
## 
## $gp_dead
## [1] "integer"
## 
## $gp1_age_1
## [1] "character"
## 
## $gp1_age_2
## [1] "integer"
## 
## $gp1_control_1
## [1] "integer"
## 
## $gp1_close_1
## [1] "integer"
## 
## $gp2_age_1
## [1] "character"
## 
## $gp2_age_2
## [1] "integer"
## 
## $gp2_control_1
## [1] "integer"
## 
## $gp2_close_1
## [1] "integer"
## 
## $gp3_age_1
## [1] "character"
## 
## $gp3_age_2
## [1] "integer"
## 
## $gp3_control_1
## [1] "integer"
## 
## $gp3_close_1
## [1] "integer"
## 
## $gp4_age_1
## [1] "character"
## 
## $gp4_age_2
## [1] "integer"
## 
## $gp4_control_1
## [1] "integer"
## 
## $gp4_close_1
## [1] "integer"
## 
## $stress
## [1] "integer"
## 
## $income
## [1] "character"
## 
## $household
## [1] "integer"
## 
## $attention_fruit
## [1] "character"
## 
## $attention_smoker
## [1] "character"
## 
## $attention_4
## [1] "integer"
## 
## $PROLIFIC_PID
## [1] "character"
## 
## $status
## [1] "character"
## 
## $time_taken
## [1] "character"
## 
## $num_approvals
## [1] "integer"
## 
## $num_rejections
## [1] "integer"
## 
## $prolific_score
## [1] "integer"
## 
## $Country.of.Birth
## [1] "character"
## 
## $Current.Country.of.Residence
## [1] "character"
## 
## $Employment.Status
## [1] "character"
## 
## $ethnicity
## [1] "character"
## 
## $First.Language
## [1] "character"
## 
## $Nationality
## [1] "character"
## 
## $Student.Status
## [1] "character"
## 
## $personal_income
## [1] "character"
## 
## $SES_subj
## [1] "integer"
## 
## $YPLL_p1
## [1] "integer"
## 
## $YPLL_p2
## [1] "integer"
## 
## $YPLL_gp1
## [1] "integer"
## 
## $YPLL_gp2
## [1] "integer"
## 
## $YPLL_gp3
## [1] "integer"
## 
## $YPLL_gp4
## [1] "integer"
## 
## $YPLL_sum
## [1] "integer"
## 
## $YPLL_dummy
## [1] "integer"
## 
## $n_deaths
## [1] "integer"
## 
## $n_deaths_cat
## [1] "character"
## 
## $p1_prem
## [1] "integer"
## 
## $p2_prem
## [1] "integer"
## 
## $gp1_prem
## [1] "integer"
## 
## $gp2_prem
## [1] "integer"
## 
## $gp3_prem
## [1] "integer"
## 
## $gp4_prem
## [1] "integer"
## 
## $n_prem
## [1] "character"
## 
## $patience_score
## [1] "integer"
## 
## $controllability
## [1] "character"
## 
## $closeness
## [1] "character"
## 
## $look_after_health_log
## [1] "character"
## 
## $look_after_health_sqrt
## [1] "character"
## 
## $patience_score_bi
## [1] "integer"
cols.num <- c("look_after_health_log","look_after_health_sqrt","personal_income","controllability","closeness")
d[cols.num] <- lapply(d[cols.num],as.numeric)
sapply(d[cols.num],class)
##  look_after_health_log look_after_health_sqrt        personal_income 
##              "numeric"              "numeric"              "numeric" 
##        controllability              closeness 
##              "numeric"              "numeric"
cols.factor <- c("checkup","breastfeed_length","YPLL_dummy","patience_score_bi")
d[cols.factor] <- lapply(d[cols.factor],as.factor)
sapply(d[cols.factor],class)
##           checkup breastfeed_length        YPLL_dummy patience_score_bi 
##          "factor"          "factor"          "factor"          "factor"
################################
######## MAIN ANALYSIS #########
################################

### Creation of additional dataframes for the YPLL_sum analyses ####

# all the YPLL_sum analyses are done on a sub-sample excluding participants who reported one of their relative died before the age of 20 (noted as 19) as that seems unreliable
d3 <- d[-c(which(d$parent1_age_2 == 19 | d$parent2_age_2 == 19 | d$gp1_age_2 == 19 | d$gp2_age_2 == 19 | d$gp3_age_2 == 19 | d$gp4_age_2 == 19)),]

cor.test(d3$age,d3$YPLL_sum)
## 
##  Pearson's product-moment correlation
## 
## data:  d3$age and d3$YPLL_sum
## t = 6.7276, df = 385, p-value = 6.261e-11
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.2321557 0.4107430
## sample estimates:
##       cor 
## 0.3243364
plot(d3$age,d3$YPLL_sum) 

# visually, participants younger than 30 yo might have a lower YPLL_sum

d5 <- d3%>% filter(age >= 30)
## filter: removed 108 rows (19%), 459 rows remaining
cor.test(d5$age,d5$YPLL_sum) 
## 
##  Pearson's product-moment correlation
## 
## data:  d5$age and d5$YPLL_sum
## t = 3.3271, df = 296, p-value = 0.0009884
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.07792503 0.29707679
## sample estimates:
##       cor 
## 0.1898647
# the correlation if quite small for this subsample

d5b <- d3%>% filter(age >= 40)
## filter: removed 213 rows (38%), 354 rows remaining
d5c <- d3%>% filter(age >= 50)
## filter: removed 318 rows (56%), 249 rows remaining
cor.test(d5b$age,d5b$YPLL_sum)
## 
##  Pearson's product-moment correlation
## 
## data:  d5b$age and d5b$YPLL_sum
## t = 3.1908, df = 216, p-value = 0.00163
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.08158391 0.33557937
## sample estimates:
##       cor 
## 0.2121619
cor.test(d5c$age,d5c$YPLL_sum)
## 
##  Pearson's product-moment correlation
## 
## data:  d5c$age and d5c$YPLL_sum
## t = 2.95, df = 154, p-value = 0.003674
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.07692798 0.37479286
## sample estimates:
##      cor 
## 0.231273
# actually the correlation increase when we restrict for 40+ or 50+ so might as well restrict to 30+ to increase power

d6 <- d3 %>% filter (age >=40 & age <= 60)
## filter: removed 342 rows (60%), 225 rows remaining
cor.test(d6$age,d6$YPLL_sum)
## 
##  Pearson's product-moment correlation
## 
## data:  d6$age and d6$YPLL_sum
## t = 0.34778, df = 134, p-value = 0.7286
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1390058  0.1973649
## sample estimates:
##        cor 
## 0.03002974
plot(d6$age,d6$YPLL_sum)

# interesting case study to see what happens to the relationship between YPLL_sum and the outcome variables when YPLL_sum does not vary with age

#####################################
######## Looking after health #######
#####################################
### Choosing the right transformations of the variables based on hist of residuals ####

hist(d3$look_after_health) # right-skewed

hist(d3$YPLL_sum) # highly left-skewed

# basic model
lm1 <- glm(look_after_health ~ scale(YPLL_sum) + age + gender + ethnicity,data=d3) 
hist(lm1$residuals) # without any transformation of the variables, the distribution of the residuals is right-skewed

plot(lm1)

plot(lm1$residuals ~ lm1$fitted.values) #shotgun pattern

# with look_after_health_sqrt = sqrt(max(x+1)-x)
lm2 <- glm(look_after_health_sqrt ~ scale(YPLL_sum) + age + gender + ethnicity,data=d3)
hist(lm2$residuals) # looks much better

plot(lm2)

plot(lm2$residuals ~ lm2$fitted.values) # much more evenly distributed

# 1/x, log(x), sqrt(x), log(K-x) do not bring any improvements, I'll skip those here do stay concise

# with log(YPLL_sum+1)
lm3 <- glm(look_after_health_sqrt ~ scale(log(YPLL_sum+1)) + age + gender + ethnicity,data=d3)
hist(lm3$residuals) # looks better than lm4, but not super significantly. 

plot(lm3)

plot(lm3$residuals ~ lm3$fitted.values)

### MODELS ####
# So far, I used the sqrt transformation for effort in looking after health and the log transformation for YPLL_sum

# model on the whole (reliable) sample
lm_health1 <- glm(look_after_health_sqrt ~ scale(log(YPLL_sum+1)) + age + gender + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress), data=d3)
summary(lm_health1)
## 
## Call:
## glm(formula = look_after_health_sqrt ~ scale(log(YPLL_sum + 1)) + 
##     age + gender + ethnicity + scale(log(personal_income)) + 
##     scale(SES_subj) + scale(stress), data = d3)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.6229  -1.0235   0.0111   1.1146   4.6610  
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 -5.023741   0.386038 -13.014  < 2e-16 ***
## scale(log(YPLL_sum + 1))     0.091435   0.094583   0.967  0.33431    
## age                          0.016971   0.005989   2.834  0.00485 ** 
## genderMale                  -0.303735   0.178981  -1.697  0.09052 .  
## ethnicityBlack               0.195879   0.616203   0.318  0.75075    
## ethnicityMixed              -0.099118   0.595634  -0.166  0.86793    
## ethnicityOther              -0.251922   0.644299  -0.391  0.69602    
## ethnicityWhite              -0.674405   0.325400  -2.073  0.03890 *  
## scale(log(personal_income))  0.086843   0.095693   0.908  0.36472    
## scale(SES_subj)              0.202549   0.094811   2.136  0.03330 *  
## scale(stress)               -0.238791   0.095601  -2.498  0.01292 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 2.856502)
## 
##     Null deviance: 1201.2  on 385  degrees of freedom
## Residual deviance: 1071.2  on 375  degrees of freedom
##   (181 observations deleted due to missingness)
## AIC: 1513.4
## 
## Number of Fisher Scoring iterations: 2
plot_model(lm_health1, type="est",show.values = TRUE)

plot_model(lm_health1, type="pred",terms="YPLL_sum")

# It would seem the higher the number of years of life lost in the close family, the more participants look after their health (contrary to predictions), but the effect is not significant

# model on 30+
lm_health2 <- glm(look_after_health_sqrt ~ scale(log(YPLL_sum+1)) + age + gender + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress), data=d5)
summary(lm_health2) # SES subj loses its significance whereas personal income becomes significant, the estimate and p-values for YPLL_sum remain comparable
## 
## Call:
## glm(formula = look_after_health_sqrt ~ scale(log(YPLL_sum + 1)) + 
##     age + gender + ethnicity + scale(log(personal_income)) + 
##     scale(SES_subj) + scale(stress), data = d5)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.4899  -0.9821   0.0612   0.8968   4.8386  
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 -5.501765   0.525864 -10.462  < 2e-16 ***
## scale(log(YPLL_sum + 1))     0.102756   0.100445   1.023  0.30717    
## age                          0.025949   0.008021   3.235  0.00136 ** 
## genderMale                  -0.374705   0.203705  -1.839  0.06689 .  
## ethnicityBlack               0.591686   0.737402   0.802  0.42299    
## ethnicityMixed              -0.107050   0.702716  -0.152  0.87903    
## ethnicityOther              -0.727053   0.780666  -0.931  0.35247    
## ethnicityWhite              -0.635929   0.397490  -1.600  0.11073    
## scale(log(personal_income))  0.226734   0.111586   2.032  0.04309 *  
## scale(SES_subj)              0.162983   0.107599   1.515  0.13094    
## scale(stress)               -0.274004   0.107054  -2.559  0.01100 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 2.801055)
## 
##     Null deviance: 929.19  on 296  degrees of freedom
## Residual deviance: 801.10  on 286  degrees of freedom
##   (162 observations deleted due to missingness)
## AIC: 1161.5
## 
## Number of Fisher Scoring iterations: 2
plot_model(lm_health2, type="est",show.values = TRUE)

# model on 40-60 yo
lm_health3 <- glm(look_after_health_sqrt ~ scale(log(YPLL_sum+1)) + age + gender + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress), data=d6)
summary(lm_health3) # nothing remains significant, the estimate for YPLL_sum remain comparable, less significant
## 
## Call:
## glm(formula = look_after_health_sqrt ~ scale(log(YPLL_sum + 1)) + 
##     age + gender + ethnicity + scale(log(personal_income)) + 
##     scale(SES_subj) + scale(stress), data = d6)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -3.7851  -0.9763   0.0121   0.8909   4.9124  
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 -5.95378    1.19575  -4.979 2.09e-06 ***
## scale(log(YPLL_sum + 1))     0.10291    0.14383   0.716   0.4756    
## age                          0.03328    0.02172   1.532   0.1280    
## genderMale                  -0.30861    0.29708  -1.039   0.3009    
## ethnicityBlack              -0.67055    1.09358  -0.613   0.5409    
## ethnicityMixed              -0.22174    0.99452  -0.223   0.8239    
## ethnicityOther              -1.13891    0.99193  -1.148   0.2531    
## ethnicityWhite              -0.84171    0.57600  -1.461   0.1465    
## scale(log(personal_income))  0.32448    0.16839   1.927   0.0563 .  
## scale(SES_subj)              0.19528    0.16107   1.212   0.2277    
## scale(stress)               -0.09341    0.15960  -0.585   0.5594    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 2.624503)
## 
##     Null deviance: 374.06  on 134  degrees of freedom
## Residual deviance: 325.44  on 124  degrees of freedom
##   (90 observations deleted due to missingness)
## AIC: 525.9
## 
## Number of Fisher Scoring iterations: 2
plot_model(lm_health3, type="est",show.values = TRUE)

##############################
####### PATIENCE SCORE #######
##############################

# Falk's 2016 future discounting measure translates into a patience score : a higher patience score means a lower time discounting

# model on the whole (reliable) sample
lm_discounting1 <- glm(patience_score ~ scale(log(YPLL_sum+1)) + gender + age + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress),data=d3)
summary(lm_discounting1) # nothing remains significant, the estimate for YPLL_sum remain comparable, less significant
## 
## Call:
## glm(formula = patience_score ~ scale(log(YPLL_sum + 1)) + gender + 
##     age + ethnicity + scale(log(personal_income)) + scale(SES_subj) + 
##     scale(stress), data = d3)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -20.7138   -9.1055    0.0212    9.4152   19.3197  
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 13.38133    2.37420   5.636 3.42e-08 ***
## scale(log(YPLL_sum + 1))    -0.63696    0.58170  -1.095  0.27422    
## genderMale                   1.15322    1.10076   1.048  0.29547    
## age                          0.11394    0.03683   3.093  0.00213 ** 
## ethnicityBlack              -6.20042    3.78975  -1.636  0.10266    
## ethnicityMixed              -1.85514    3.66325  -0.506  0.61286    
## ethnicityOther              -3.60792    3.96254  -0.911  0.36314    
## ethnicityWhite              -2.66011    2.00127  -1.329  0.18459    
## scale(log(personal_income))  0.08003    0.58853   0.136  0.89191    
## scale(SES_subj)              1.63946    0.58310   2.812  0.00519 ** 
## scale(stress)                1.02111    0.58796   1.737  0.08326 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 108.0459)
## 
##     Null deviance: 43132  on 385  degrees of freedom
## Residual deviance: 40517  on 375  degrees of freedom
##   (181 observations deleted due to missingness)
## AIC: 2915.7
## 
## Number of Fisher Scoring iterations: 2
plot_model(lm_discounting1, type="est",show.values = TRUE)

plot_model(lm_discounting1, type="pred",terms="YPLL_sum")

# It would seem the higher the number of years of life lost in the close family, the more participants discount the future, but the effect is not significant

# model on 30+
lm_discounting1b <- glm(patience_score ~ scale(log(YPLL_sum+1)) + gender + age + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress),data=d5)
summary(lm_discounting1b) # the effect of YPLL_sum is closer to a null effect, SES_subj becomes slightly stronger
## 
## Call:
## glm(formula = patience_score ~ scale(log(YPLL_sum + 1)) + gender + 
##     age + ethnicity + scale(log(personal_income)) + scale(SES_subj) + 
##     scale(stress), data = d5)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -22.0124   -8.6122    0.2276    9.1196   19.4772  
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 11.25515    3.21630   3.499 0.000541 ***
## scale(log(YPLL_sum + 1))     0.05161    0.61434   0.084 0.933106    
## genderMale                   1.62318    1.24590   1.303 0.193688    
## age                          0.13737    0.04906   2.800 0.005458 ** 
## ethnicityBlack              -1.06577    4.51011  -0.236 0.813364    
## ethnicityMixed              -1.34423    4.29797  -0.313 0.754692    
## ethnicityOther               3.66733    4.77473   0.768 0.443079    
## ethnicityWhite              -2.63990    2.43114  -1.086 0.278450    
## scale(log(personal_income))  0.34722    0.68248   0.509 0.611311    
## scale(SES_subj)              1.79857    0.65810   2.733 0.006667 ** 
## scale(stress)                0.41075    0.65477   0.627 0.530950    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 104.7824)
## 
##     Null deviance: 32536  on 296  degrees of freedom
## Residual deviance: 29968  on 286  degrees of freedom
##   (162 observations deleted due to missingness)
## AIC: 2237.3
## 
## Number of Fisher Scoring iterations: 2
plot_model(lm_discounting1b, type="est",show.values = TRUE)

# model on 40-60 yo
lm_discounting1c <- glm(patience_score ~ scale(log(YPLL_sum+1)) + gender + age + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress),data=d6)
summary(lm_discounting1c) # only the effect of subj SES remains. The estimate for YPLL_sum is closer to what it is on the 1st model, slightly stronger, but still not significant
## 
## Call:
## glm(formula = patience_score ~ scale(log(YPLL_sum + 1)) + gender + 
##     age + ethnicity + scale(log(personal_income)) + scale(SES_subj) + 
##     scale(stress), data = d6)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -19.7297   -8.2638    0.0664    8.4795   16.9225  
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)                 13.41511    7.48416   1.792   0.0755 .
## scale(log(YPLL_sum + 1))    -1.40869    0.90021  -1.565   0.1202  
## genderMale                   2.08763    1.85938   1.123   0.2637  
## age                          0.08824    0.13593   0.649   0.5175  
## ethnicityBlack               8.97654    6.84464   1.311   0.1921  
## ethnicityMixed              -4.00375    6.22463  -0.643   0.5213  
## ethnicityOther               1.76219    6.20846   0.284   0.7770  
## ethnicityWhite              -3.30666    3.60512  -0.917   0.3608  
## scale(log(personal_income)) -0.49742    1.05394  -0.472   0.6378  
## scale(SES_subj)              2.38014    1.00812   2.361   0.0198 *
## scale(stress)                1.82824    0.99893   1.830   0.0696 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 102.8133)
## 
##     Null deviance: 14473  on 134  degrees of freedom
## Residual deviance: 12749  on 124  degrees of freedom
##   (90 observations deleted due to missingness)
## AIC: 1021.1
## 
## Number of Fisher Scoring iterations: 2
plot_model(lm_discounting1c, type="est",show.values = TRUE)

### As I saw graphically there might be a gender interaction, I added an interaction with gender
# model on the whole (reliable) sample
lm_discounting2a <- glm(patience_score ~ scale(log(YPLL_sum+1))*gender + age + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress),data=d3)
summary(lm_discounting2a) # for women, YPLL_sum has a significant effect on time discounting
## 
## Call:
## glm(formula = patience_score ~ scale(log(YPLL_sum + 1)) * gender + 
##     age + ethnicity + scale(log(personal_income)) + scale(SES_subj) + 
##     scale(stress), data = d3)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -19.9268   -8.9655    0.0683    9.4155   19.3667  
## 
## Coefficients:
##                                     Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                         13.44839    2.36318   5.691 2.56e-08 ***
## scale(log(YPLL_sum + 1))            -1.65952    0.75090  -2.210  0.02771 *  
## genderMale                           1.10421    1.09579   1.008  0.31426    
## age                                  0.11385    0.03666   3.105  0.00204 ** 
## ethnicityBlack                      -5.66209    3.78022  -1.498  0.13502    
## ethnicityMixed                      -1.92794    3.64608  -0.529  0.59728    
## ethnicityOther                      -3.32420    3.94603  -0.842  0.40009    
## ethnicityWhite                      -2.74357    1.99218  -1.377  0.16928    
## scale(log(personal_income))          0.17807    0.58754   0.303  0.76199    
## scale(SES_subj)                      1.57681    0.58108   2.714  0.00696 ** 
## scale(stress)                        0.95402    0.58602   1.628  0.10437    
## scale(log(YPLL_sum + 1)):genderMale  2.29166    1.07166   2.138  0.03313 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 107.0262)
## 
##     Null deviance: 43132  on 385  degrees of freedom
## Residual deviance: 40028  on 374  degrees of freedom
##   (181 observations deleted due to missingness)
## AIC: 2913
## 
## Number of Fisher Scoring iterations: 2
plot_model(lm_discounting2a, type="est",show.values = TRUE)

# model on 30+
lm_discounting2b <- glm(patience_score ~ scale(log(YPLL_sum+1))*gender + age + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress),data=d5)
summary(lm_discounting2b) # the effect vanishes on the 30+ subsample
## 
## Call:
## glm(formula = patience_score ~ scale(log(YPLL_sum + 1)) * gender + 
##     age + ethnicity + scale(log(personal_income)) + scale(SES_subj) + 
##     scale(stress), data = d5)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -21.5264   -8.7891    0.1426    9.0069   19.3633  
## 
## Coefficients:
##                                     Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                         11.30378    3.21249   3.519 0.000505 ***
## scale(log(YPLL_sum + 1))            -0.63475    0.80666  -0.787 0.432008    
## genderMale                           1.55306    1.24549   1.247 0.213441    
## age                                  0.13571    0.04901   2.769 0.005997 ** 
## ethnicityBlack                      -0.71748    4.51230  -0.159 0.873778    
## ethnicityMixed                      -1.15656    4.29497  -0.269 0.787907    
## ethnicityOther                       3.65563    4.76876   0.767 0.443967    
## ethnicityWhite                      -2.57377    2.42862  -1.060 0.290146    
## scale(log(personal_income))          0.44709    0.68587   0.652 0.515024    
## scale(SES_subj)                      1.75736    0.65803   2.671 0.008005 ** 
## scale(stress)                        0.30903    0.65854   0.469 0.639237    
## scale(log(YPLL_sum + 1)):genderMale  1.59754    1.21889   1.311 0.191029    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 104.5201)
## 
##     Null deviance: 32536  on 296  degrees of freedom
## Residual deviance: 29788  on 285  degrees of freedom
##   (162 observations deleted due to missingness)
## AIC: 2237.5
## 
## Number of Fisher Scoring iterations: 2
plot_model(lm_discounting2b, type="est",show.values = TRUE)

# model on 40-60 yo
lm_discounting2c <- glm(patience_score ~ scale(log(YPLL_sum+1))*gender + age + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress),data=d6)
summary(lm_discounting2c) # same
## 
## Call:
## glm(formula = patience_score ~ scale(log(YPLL_sum + 1)) * gender + 
##     age + ethnicity + scale(log(personal_income)) + scale(SES_subj) + 
##     scale(stress), data = d6)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -19.5781   -8.4097    0.4548    8.7007   17.0060  
## 
## Coefficients:
##                                     Estimate Std. Error t value Pr(>|t|)  
## (Intercept)                         13.95341    7.57536   1.842   0.0679 .
## scale(log(YPLL_sum + 1))            -1.06028    1.11935  -0.947   0.3454  
## genderMale                           2.12377    1.86609   1.138   0.2573  
## age                                  0.07682    0.13804   0.556   0.5789  
## ethnicityBlack                       8.64184    6.89405   1.254   0.2124  
## ethnicityMixed                      -3.94785    6.24375  -0.632   0.5284  
## ethnicityOther                       1.61746    6.23269   0.260   0.7957  
## ethnicityWhite                      -3.25254    3.61714  -0.899   0.3703  
## scale(log(personal_income))         -0.64173    1.09198  -0.588   0.5578  
## scale(SES_subj)                      2.47750    1.02784   2.410   0.0174 *
## scale(stress)                        1.90983    1.01377   1.884   0.0619 .
## scale(log(YPLL_sum + 1)):genderMale -1.04784    1.99005  -0.527   0.5995  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 103.4161)
## 
##     Null deviance: 14473  on 134  degrees of freedom
## Residual deviance: 12720  on 123  degrees of freedom
##   (90 observations deleted due to missingness)
## AIC: 1022.8
## 
## Number of Fisher Scoring iterations: 2
plot_model(lm_discounting2c, type="est",show.values = TRUE)

#################################
###### Secondary analyses #######
#################################

####### Effect of controllability and closeness of the age of death ####
### On effort in looking after health ####
### CONTROL ###
lm_health_control <- glm(look_after_health_sqrt ~ scale(log(YPLL_sum+1)) + age + gender + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress) + scale(controllability), data=d3)
summary(lm_health_control)
## 
## Call:
## glm(formula = look_after_health_sqrt ~ scale(log(YPLL_sum + 1)) + 
##     age + gender + ethnicity + scale(log(personal_income)) + 
##     scale(SES_subj) + scale(stress) + scale(controllability), 
##     data = d3)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.7072  -1.0169  -0.0247   1.1338   4.3895  
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 -5.02221    0.39298 -12.780  < 2e-16 ***
## scale(log(YPLL_sum + 1))     0.08441    0.09974   0.846  0.39793    
## age                          0.01680    0.00606   2.772  0.00586 ** 
## genderMale                  -0.35602    0.18292  -1.946  0.05240 .  
## ethnicityBlack               0.20819    0.64289   0.324  0.74625    
## ethnicityMixed               0.05386    0.62265   0.087  0.93112    
## ethnicityOther              -0.34783    0.64635  -0.538  0.59081    
## ethnicityWhite              -0.65614    0.33572  -1.954  0.05142 .  
## scale(log(personal_income))  0.09354    0.09878   0.947  0.34433    
## scale(SES_subj)              0.21736    0.09540   2.278  0.02328 *  
## scale(stress)               -0.25796    0.09627  -2.679  0.00771 ** 
## scale(controllability)       0.20970    0.08650   2.424  0.01583 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 2.823568)
## 
##     Null deviance: 1161.3  on 371  degrees of freedom
## Residual deviance: 1016.5  on 360  degrees of freedom
##   (195 observations deleted due to missingness)
## AIC: 1455.6
## 
## Number of Fisher Scoring iterations: 2
# a higher controllability means "they could have done more to look after their health"
# The more people feel their dead relatives were responsible for their death, the more they look after their health
# The more people feel their relatives' death was uncontrollable, the less they look after their health

lm_health_control2 <- glm(look_after_health_sqrt ~ scale(log(YPLL_sum+1))*scale(controllability) + age + gender + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress), data=d3)
summary(lm_health_control2)
## 
## Call:
## glm(formula = look_after_health_sqrt ~ scale(log(YPLL_sum + 1)) * 
##     scale(controllability) + age + gender + ethnicity + scale(log(personal_income)) + 
##     scale(SES_subj) + scale(stress), data = d3)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.6955  -0.9898  -0.0022   1.1235   4.3897  
## 
## Coefficients:
##                                                  Estimate Std. Error t value
## (Intercept)                                     -5.012043   0.394532 -12.704
## scale(log(YPLL_sum + 1))                         0.081627   0.100177   0.815
## scale(controllability)                           0.208768   0.086645   2.409
## age                                              0.016735   0.006071   2.757
## genderMale                                      -0.356037   0.183142  -1.944
## ethnicityBlack                                   0.203029   0.643847   0.315
## ethnicityMixed                                   0.049491   0.623533   0.079
## ethnicityOther                                  -0.379551   0.653471  -0.581
## ethnicityWhite                                  -0.662203   0.336574  -1.967
## scale(log(personal_income))                      0.093885   0.098910   0.949
## scale(SES_subj)                                  0.216067   0.095588   2.260
## scale(stress)                                   -0.258177   0.096394  -2.678
## scale(log(YPLL_sum + 1)):scale(controllability) -0.030603   0.087547  -0.350
##                                                 Pr(>|t|)    
## (Intercept)                                      < 2e-16 ***
## scale(log(YPLL_sum + 1))                         0.41571    
## scale(controllability)                           0.01648 *  
## age                                              0.00614 ** 
## genderMale                                       0.05267 .  
## ethnicityBlack                                   0.75269    
## ethnicityMixed                                   0.93678    
## ethnicityOther                                   0.56172    
## ethnicityWhite                                   0.04990 *  
## scale(log(personal_income))                      0.34316    
## scale(SES_subj)                                  0.02439 *  
## scale(stress)                                    0.00774 ** 
## scale(log(YPLL_sum + 1)):scale(controllability)  0.72687    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 2.830469)
## 
##     Null deviance: 1161.3  on 371  degrees of freedom
## Residual deviance: 1016.1  on 359  degrees of freedom
##   (195 observations deleted due to missingness)
## AIC: 1457.5
## 
## Number of Fisher Scoring iterations: 2
# There is no interaction between controllability and YPLL_sum

plot_model(lm_health_control, type="est",show.values=TRUE)

plot_model(lm_health_control, type="pred",terms="controllability") 

plot(d3$controllability,d3$look_after_health)

### CLOSENESS ###
lm_health_control_close <- glm(look_after_health_sqrt ~ scale(log(YPLL_sum+1)) + age + gender + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress) + scale(controllability) + scale(closeness), data=d3)
summary(lm_health_control_close) # no impact of closeness to the relative
## 
## Call:
## glm(formula = look_after_health_sqrt ~ scale(log(YPLL_sum + 1)) + 
##     age + gender + ethnicity + scale(log(personal_income)) + 
##     scale(SES_subj) + scale(stress) + scale(controllability) + 
##     scale(closeness), data = d3)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.5710  -1.0525  -0.0596   1.1338   4.3402  
## 
## Coefficients:
##                              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 -4.976459   0.395546 -12.581  < 2e-16 ***
## scale(log(YPLL_sum + 1))     0.105034   0.101787   1.032  0.30281    
## age                          0.015735   0.006151   2.558  0.01093 *  
## genderMale                  -0.355798   0.182911  -1.945  0.05253 .  
## ethnicityBlack               0.185890   0.643244   0.289  0.77276    
## ethnicityMixed               0.087962   0.623531   0.141  0.88789    
## ethnicityOther              -0.378298   0.647021  -0.585  0.55913    
## ethnicityWhite              -0.655948   0.335704  -1.954  0.05148 .  
## scale(log(personal_income))  0.099611   0.098962   1.007  0.31482    
## scale(SES_subj)              0.209907   0.095679   2.194  0.02889 *  
## scale(stress)               -0.261924   0.096350  -2.718  0.00688 ** 
## scale(controllability)       0.201739   0.086851   2.323  0.02075 *  
## scale(closeness)             0.090897   0.089651   1.014  0.31132    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 2.823348)
## 
##     Null deviance: 1161.3  on 371  degrees of freedom
## Residual deviance: 1013.6  on 359  degrees of freedom
##   (195 observations deleted due to missingness)
## AIC: 1456.6
## 
## Number of Fisher Scoring iterations: 2
lm_health_control_close2 <- glm(look_after_health_sqrt ~ scale(log(YPLL_sum+1))*scale(closeness) + age + gender + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress) + scale(controllability), data=d3)
summary(lm_health_control_close2) # no interaction between closeness and YPLL_sum
## 
## Call:
## glm(formula = look_after_health_sqrt ~ scale(log(YPLL_sum + 1)) * 
##     scale(closeness) + age + gender + ethnicity + scale(log(personal_income)) + 
##     scale(SES_subj) + scale(stress) + scale(controllability), 
##     data = d3)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -5.3378  -1.0638  -0.0581   1.0644   4.2986  
## 
## Coefficients:
##                                            Estimate Std. Error t value Pr(>|t|)
## (Intercept)                               -4.958229   0.395601 -12.533  < 2e-16
## scale(log(YPLL_sum + 1))                   0.100585   0.101793   0.988  0.32376
## scale(closeness)                           0.099638   0.089894   1.108  0.26844
## age                                        0.015435   0.006152   2.509  0.01255
## genderMale                                -0.341443   0.183194  -1.864  0.06316
## ethnicityBlack                             0.219923   0.643484   0.342  0.73273
## ethnicityMixed                             0.091430   0.623162   0.147  0.88344
## ethnicityOther                            -0.368730   0.646681  -0.570  0.56891
## ethnicityWhite                            -0.649834   0.335540  -1.937  0.05357
## scale(log(personal_income))                0.095589   0.098959   0.966  0.33473
## scale(SES_subj)                            0.200073   0.095973   2.085  0.03781
## scale(stress)                             -0.260419   0.096300  -2.704  0.00717
## scale(controllability)                     0.203351   0.086809   2.343  0.01970
## scale(log(YPLL_sum + 1)):scale(closeness)  0.112886   0.094289   1.197  0.23201
##                                              
## (Intercept)                               ***
## scale(log(YPLL_sum + 1))                     
## scale(closeness)                             
## age                                       *  
## genderMale                                .  
## ethnicityBlack                               
## ethnicityMixed                               
## ethnicityOther                               
## ethnicityWhite                            .  
## scale(log(personal_income))                  
## scale(SES_subj)                           *  
## scale(stress)                             ** 
## scale(controllability)                    *  
## scale(log(YPLL_sum + 1)):scale(closeness)    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 2.819944)
## 
##     Null deviance: 1161.3  on 371  degrees of freedom
## Residual deviance: 1009.5  on 358  degrees of freedom
##   (195 observations deleted due to missingness)
## AIC: 1457.1
## 
## Number of Fisher Scoring iterations: 2
### On temporal discounting ####
### CONTROL ###
lm_patience_control <- glm(patience_score ~ scale(log(YPLL_sum+1)) + age + gender + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress) + scale(controllability), data=d3)
summary(lm_patience_control) # no impact of controllability on future discounting
## 
## Call:
## glm(formula = patience_score ~ scale(log(YPLL_sum + 1)) + age + 
##     gender + ethnicity + scale(log(personal_income)) + scale(SES_subj) + 
##     scale(stress) + scale(controllability), data = d3)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -20.7807   -8.9990    0.4001    9.3475   18.7922  
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 13.35405    2.42671   5.503  7.1e-08 ***
## scale(log(YPLL_sum + 1))    -0.73226    0.61590  -1.189 0.235252    
## age                          0.12534    0.03742   3.349 0.000896 ***
## genderMale                   1.45156    1.12955   1.285 0.199592    
## ethnicityBlack              -5.38740    3.96996  -1.357 0.175618    
## ethnicityMixed              -0.64073    3.84494  -0.167 0.867744    
## ethnicityOther              -3.85672    3.99130  -0.966 0.334551    
## ethnicityWhite              -3.50409    2.07310  -1.690 0.091843 .  
## scale(log(personal_income))  0.52235    0.61001   0.856 0.392400    
## scale(SES_subj)              1.38745    0.58911   2.355 0.019049 *  
## scale(stress)                1.06939    0.59451   1.799 0.072892 .  
## scale(controllability)       0.09775    0.53414   0.183 0.854895    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 107.6697)
## 
##     Null deviance: 41491  on 371  degrees of freedom
## Residual deviance: 38761  on 360  degrees of freedom
##   (195 observations deleted due to missingness)
## AIC: 2810.1
## 
## Number of Fisher Scoring iterations: 2
lm_patience_control2 <- glm(patience_score ~ scale(log(YPLL_sum+1))*scale(controllability) + age + gender + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress), data=d3)
summary(lm_patience_control2) # no interaction between controllability and YPLL_sum
## 
## Call:
## glm(formula = patience_score ~ scale(log(YPLL_sum + 1)) * scale(controllability) + 
##     age + gender + ethnicity + scale(log(personal_income)) + 
##     scale(SES_subj) + scale(stress), data = d3)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -21.3864   -8.9841    0.1693    9.1168   18.8729  
## 
## Coefficients:
##                                                 Estimate Std. Error t value
## (Intercept)                                     13.58246    2.43121   5.587
## scale(log(YPLL_sum + 1))                        -0.79483    0.61732  -1.288
## scale(controllability)                           0.07678    0.53393   0.144
## age                                              0.12385    0.03741   3.311
## genderMale                                       1.45106    1.12857   1.286
## ethnicityBlack                                  -5.50340    3.96756  -1.387
## ethnicityMixed                                  -0.73894    3.84238  -0.192
## ethnicityOther                                  -4.56976    4.02686  -1.135
## ethnicityWhite                                  -3.64044    2.07406  -1.755
## scale(log(personal_income))                      0.53017    0.60951   0.870
## scale(SES_subj)                                  1.35832    0.58904   2.306
## scale(stress)                                    1.06445    0.59401   1.792
## scale(log(YPLL_sum + 1)):scale(controllability) -0.68782    0.53949  -1.275
##                                                 Pr(>|t|)    
## (Intercept)                                     4.58e-08 ***
## scale(log(YPLL_sum + 1))                         0.19873    
## scale(controllability)                           0.88574    
## age                                              0.00103 ** 
## genderMale                                       0.19936    
## ethnicityBlack                                   0.16627    
## ethnicityMixed                                   0.84761    
## ethnicityOther                                   0.25721    
## ethnicityWhite                                   0.08007 .  
## scale(log(personal_income))                      0.38497    
## scale(SES_subj)                                  0.02168 *  
## scale(stress)                                    0.07398 .  
## scale(log(YPLL_sum + 1)):scale(controllability)  0.20315    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 107.483)
## 
##     Null deviance: 41491  on 371  degrees of freedom
## Residual deviance: 38586  on 359  degrees of freedom
##   (195 observations deleted due to missingness)
## AIC: 2810.4
## 
## Number of Fisher Scoring iterations: 2
### CLOSENESS ###
lm_patience_control_close <- glm(patience_score ~ scale(log(YPLL_sum+1)) + age + gender + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress) + scale(controllability) + scale(closeness), data=d3)
summary(lm_patience_control_close) # significant impact of closeness!
## 
## Call:
## glm(formula = patience_score ~ scale(log(YPLL_sum + 1)) + age + 
##     gender + ethnicity + scale(log(personal_income)) + scale(SES_subj) + 
##     scale(stress) + scale(controllability) + scale(closeness), 
##     data = d3)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -22.0296   -8.7334    0.1982    8.8975   18.9382  
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                 12.75918    2.43052   5.250 2.62e-07 ***
## scale(log(YPLL_sum + 1))    -1.00042    0.62545  -1.600 0.110584    
## age                          0.13920    0.03779   3.683 0.000266 ***
## genderMale                   1.44874    1.12394   1.289 0.198234    
## ethnicityBlack              -5.09743    3.95255  -1.290 0.198001    
## ethnicityMixed              -1.08417    3.83142  -0.283 0.777365    
## ethnicityOther              -3.46048    3.97576  -0.870 0.384666    
## ethnicityWhite              -3.50653    2.06280  -1.700 0.090018 .  
## scale(log(personal_income))  0.44337    0.60809   0.729 0.466411    
## scale(SES_subj)              1.48442    0.58792   2.525 0.012004 *  
## scale(stress)                1.12097    0.59205   1.893 0.059111 .  
## scale(controllability)       0.20128    0.53367   0.377 0.706273    
## scale(closeness)            -1.18195    0.55088  -2.146 0.032578 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 106.6027)
## 
##     Null deviance: 41491  on 371  degrees of freedom
## Residual deviance: 38270  on 359  degrees of freedom
##   (195 observations deleted due to missingness)
## AIC: 2807.4
## 
## Number of Fisher Scoring iterations: 2
# The more the participants felt close to their relatives who died, the less patient they are --> the more they discount the future

lm_patience_control_close2 <- glm(patience_score ~ scale(log(YPLL_sum+1))*scale(closeness) + age + gender + ethnicity + scale(log(personal_income)) + scale(SES_subj) + scale(stress) + scale(controllability), data=d3)
summary(lm_patience_control_close2) # but no interaction between closeness and YPLL_sum
## 
## Call:
## glm(formula = patience_score ~ scale(log(YPLL_sum + 1)) * scale(closeness) + 
##     age + gender + ethnicity + scale(log(personal_income)) + 
##     scale(SES_subj) + scale(stress) + scale(controllability), 
##     data = d3)
## 
## Deviance Residuals: 
##      Min        1Q    Median        3Q       Max  
## -21.3872   -8.6517    0.3412    9.0607   19.0554  
## 
## Coefficients:
##                                           Estimate Std. Error t value Pr(>|t|)
## (Intercept)                               12.85514    2.43215   5.286 2.18e-07
## scale(log(YPLL_sum + 1))                  -1.02384    0.62583  -1.636 0.102721
## scale(closeness)                          -1.13594    0.55267  -2.055 0.040568
## age                                        0.13763    0.03782   3.639 0.000314
## genderMale                                 1.52429    1.12627   1.353 0.176783
## ethnicityBlack                            -4.91830    3.95613  -1.243 0.214605
## ethnicityMixed                            -1.06592    3.83119  -0.278 0.781004
## ethnicityOther                            -3.41012    3.97579  -0.858 0.391619
## ethnicityWhite                            -3.47435    2.06290  -1.684 0.093013
## scale(log(personal_income))                0.42219    0.60840   0.694 0.488170
## scale(SES_subj)                            1.43266    0.59004   2.428 0.015672
## scale(stress)                              1.12889    0.59205   1.907 0.057356
## scale(controllability)                     0.20977    0.53370   0.393 0.694521
## scale(log(YPLL_sum + 1)):scale(closeness)  0.59417    0.57969   1.025 0.306062
##                                              
## (Intercept)                               ***
## scale(log(YPLL_sum + 1))                     
## scale(closeness)                          *  
## age                                       ***
## genderMale                                   
## ethnicityBlack                               
## ethnicityMixed                               
## ethnicityOther                               
## ethnicityWhite                            .  
## scale(log(personal_income))                  
## scale(SES_subj)                           *  
## scale(stress)                             .  
## scale(controllability)                       
## scale(log(YPLL_sum + 1)):scale(closeness)    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 106.5876)
## 
##     Null deviance: 41491  on 371  degrees of freedom
## Residual deviance: 38158  on 358  degrees of freedom
##   (195 observations deleted due to missingness)
## AIC: 2808.3
## 
## Number of Fisher Scoring iterations: 2